home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 June / EnigmA AMIGA RUN 19 (1997)(G.R. Edizioni)(IT)[!][issue 1997-06][EAR-CD III].iso / softwareupdate / system / atapi_pnp300 / developer_kit / playtrack.c < prev    next >
C/C++ Source or Header  |  1996-02-04  |  2KB  |  86 lines

  1. /****************************************************************************
  2. *
  3. *
  4. *   $VER: PlayTrack.c  1.0 (22 Jan 1996) by M_Campinoti CD++
  5. *
  6. *   $HISTORY:
  7. *
  8. *   22 Jan 1996 : 001.000 : First and Last release of an example that show
  9. *                           how to play audio tracks by means of
  10. *                           CD_PLAYTRACK command.
  11. *                           Didactical use, so CLI only      :)
  12. *
  13. ****************************************************************************/
  14.  
  15. #include <proto/exec.h>
  16. #include <exec/devices.h>
  17. #include <exec/io.h>
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21.  
  22. #include "atapi_cd.h"
  23.  
  24. #define START_TRACK      0x01
  25. #define TRACKS_TO_PLAY    0x01
  26.  
  27. main (UBYTE argc,UBYTE** argv)
  28. {
  29.     struct IOStdReq      *ioreq  ;
  30.     struct MsgPort       *reply  ;
  31.     UBYTE                tracknumber;
  32.     UBYTE                howmanytracks;
  33.  
  34.     tracknumber=START_TRACK;
  35.     howmanytracks=TRACKS_TO_PLAY;
  36.  
  37.     switch(argc)
  38.     {
  39.      case 0:
  40.          return;         /* it came from workbench .... */
  41.          break;
  42.      default:
  43.      case 1:
  44.          printf("USAGE: PlayTrack <tracknumber> <tracks to play>\n");
  45.          return;        /* Yes, this isn't a cool template, but is quickly ! (i'm lazy) */
  46.          break;
  47.      case 3:
  48.          howmanytracks=atoi(argv[2]);
  49.      case 2:
  50.          tracknumber=atoi(argv[1]);
  51.  
  52.     }
  53.  
  54.     if (tracknumber==0) tracknumber = 1;        /* tracknumber MUST be not zero ! */
  55.     if (howmanytracks==0) howmanytracks = 1;    /* (EX)Commodore Rules !          */
  56.  
  57.     if( reply = CreateMsgPort() )
  58.     {
  59.       if( ioreq = (struct IOStdReq *)
  60.              CreateIORequest(reply ,sizeof(struct  IOStdReq)) )
  61.       {
  62.         if(!OpenDevice("cd.device",0,(struct IORequest*)ioreq,NULL) )
  63.         {
  64.           ioreq->io_Command = CD_PLAYTRACK;
  65.           ioreq->io_Offset  = tracknumber;
  66.           ioreq->io_Length  = howmanytracks;
  67.  
  68.           printf("Start Playing at TRACK N. %d\n",tracknumber);
  69.  
  70.           DoIO((struct IORequest*)ioreq);
  71.           
  72.           if (ioreq->io_Error)
  73.                 printf("I/O error !\n");     /* analyze ioreq->io_Error to know what kind ... */
  74.                                              /* ... see atapi_cd.h for #defines of it !       */
  75.           
  76.           CloseDevice((struct IORequest *)ioreq) ;
  77.         }
  78.         
  79.         DeleteIORequest(ioreq) ;
  80.       }
  81.  
  82.       DeleteMsgPort(reply);
  83.     }
  84. }
  85.  
  86.